<template>
  <el-carousel :interval="4000" type="card" height="400px">
    <el-carousel-item v-for="(slide,index) in bannerImg" :key="index">
      <div justify="center">
        <img class="swiperimg" :src="imgUrl+slide" alt="index">
      </div>
    </el-carousel-item>
  </el-carousel>
</template>

<script setup>

import {indexImg} from "@/assets/api/indexApi";
import {ref, onBeforeMount, getCurrentInstance} from 'vue';

const imgUrl = getCurrentInstance()?.appContext.config.globalProperties.$imgUrl
const bannerImg = ref([]);
const data = {};

const findIndex = () => {
  indexImg(data).then((res) => {
    bannerImg.value = res.data.data;
  });
}

onBeforeMount(() => {
  findIndex();
})

</script>

<style scoped>
* {
  background-color: #f4f4f4;
}

.swiperimg {
  width: 700px;
  height: 400px;
  overflow: hidden;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
}

.el-carousel__item h3 {
  color: #475669;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
  text-align: center;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
</style>
